<nz-spin *ngIf="isLoading" class="modal-spin"></nz-spin>
<form nz-form *ngIf="!isLoading" [formGroup]="validateForm" (ngSubmit)="submitForm()">
  <nz-form-item>
    <nz-form-label [nzSpan]="6" nzRequired nzFor="name">姓名</nz-form-label>
    <nz-form-control [nzSpan]="18" [nzValidateStatus]="validateForm.controls['name']">
      <input type="text" nz-input formControlName="name" placeholder="姓名">
      <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('required')">请输入姓名</nz-form-explain>
      <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').hasError('maxlength')">不能超过30个字</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="6" nzRequired nzFor="phone">手机号</nz-form-label>
    <nz-form-control [nzSpan]="18" [nzValidateStatus]="validateForm.controls['phone']">
      <input type="text" nz-input formControlName="phone" placeholder="手机号,请注意手机号即为其初始账号和密码">
      <nz-form-extra style="color: orange;">说明：手机号即为默认初始化账号密码</nz-form-extra>
      <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('required')">请输入手机号</nz-form-explain>
      <nz-form-explain *ngIf="validateForm.get('phone').dirty && validateForm.get('phone').hasError('mobileValidate')">手机号码格式不正确</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="6" nzFor="idNumber">身份证号</nz-form-label>
    <nz-form-control [nzSpan]="18" [nzValidateStatus]="validateForm.controls['idNumber']">
      <input type="text" nz-input formControlName="idNumber" placeholder="身份证号">
      <nz-form-explain *ngIf="validateForm.get('idNumber').dirty && validateForm.get('idNumber').hasError('required')">请输入身份证号</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="6" nzRequired nzFor="role">角色</nz-form-label>
    <nz-form-control [nzSpan]="18" [nzValidateStatus]="validateForm.controls['role']">
      <nz-select formControlName="role" [nzPlaceHolder]="'角色'" [nzDisabled]="entity.id && entity.role == 1">
        <nz-option
          *ngFor="let option of marketSalesmanRole"
          [nzLabel]="option.value"
          [nzValue]="option.key">
        </nz-option>
      </nz-select>
      <nz-form-explain *ngIf="validateForm.get('role').dirty && validateForm.get('role').hasError('required')">请选择账号角色</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label [nzSpan]="6" nzRequired nzFor="districtId">运营中心</nz-form-label>
    <nz-form-control [nzSpan]="18" [nzValidateStatus]="validateForm.controls['districtId']">
      <nz-select formControlName="districtId" [nzPlaceHolder]="'运营中心'">
        <nz-option
          *ngFor="let option of districtOption"
          [nzLabel]="option.name"
          [nzValue]="option.id">
        </nz-option>
      </nz-select>
      <nz-form-explain *ngIf="validateForm.get('districtId').dirty && validateForm.get('districtId').hasError('required')">请选择运营中心</nz-form-explain>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item *ngIf="!entity.id || !entity.openId">
    <nz-form-label [nzSpan]="6" >温馨提示</nz-form-label>
    <nz-form-control [nzSpan]="18" >
      <nz-form-extra style="color: orange;padding-top: 10px;">请注意提醒客户使用账号登录，初次登录后客户与此账号即建立联系</nz-form-extra>
    </nz-form-control>
  </nz-form-item>
  <div class="modal-footer">
    <button nz-button type="button" (click)="close()">关闭</button>
    <button nz-button type="submit" [nzType]="'primary'" >保存</button>
  </div>
</form>
